<template>
  <div class="homeswiper">
    <van-swipe class="my-swiper" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in bannerData" :key="item.targetId">
        <img :src="item.pic" alt="" />
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      bannerData: [],
    };
  },
  mounted() {
    this.getBanner();
  },
  methods: {
    getBanner() {
      axios
        .get("/api/banner?type=2")
        .then((res) => {
          console.log(res.data.banners);
          this.bannerData = res.data.banners;
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
};
</script>
<style scoped>
  .my-swiper .van-swipe-item img{
    width: 90%;
    border-radius: 15px;
    margin-top: 10px;
  }
</style>